<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>日志查询</title>
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/easyui_my.css">
<link rel="stylesheet" type="text/css" href="${ctx}/easyui/themes/icon.css">
<link rel="stylesheet" type="text/css" href="${ctx}/css/css.css" />


<script type="text/javascript" src="${ctx}/js/jquery-1.7.min.js"></script>
<script type="text/javascript" src="${ctx}/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="${ctx }/easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="${ctx}/js/common.js"></script>

</head>
<body class="easyui-layout" options="border:false">
	<div data-options="region:'north',height:90,border:false" style="padding-left:10px;padding-right: 10px;padding-top: 5px;">
		<div class="xinxichaxunkuangz1">
			<div class="dashujtiaojianxuanxiangkuan">
				<div class="dashujtiaojianxuanxiangkuan_lie">
						<div class="tiaojian_values">
							<ul class="tiaojian_values_limian" style="width: 1200px">
								<li><span class="tiaojian_key">开始时间：</span>
									<input id="dateTimeStart" name="dateTimeStart" style="width:150px" class="easyui-datetimebox"  data-options="showSeconds:true"/>
								</li> 
								<li><span class="buchongdbiaotdsw">结束时间：</span>
									<input id="dateTimeEnd" name="dateTimeEnd" style="width:150px" class="easyui-datetimebox"  data-options="showSeconds:true"/>
								</li>
								<li>
								<input  id="optype" name="optype" class="easyui-combobox shurukuangkais " 
										data-options="
										prompt:'请选择操作类型',
										valueField:'value',
										textField:'text',
										panelHeight:'auto',
										editable:true,
										data:[
										{value:'1',text:'新增'},
										{value:'2',text:'修改'},
										{value:'3',text:'查询'},
										{value:'4',text:'删除'},
										{value:'5',text:'下载'}]"/>
								</li>
								<li>
									<input id="yhdh" name="yhdh" style="width:100px" type="text" class="shurukuangkais" value="请输入操作用户" onblur="if(this.value==''){this.value='请输入操作用户';}" onfocus="if(this.value=='请输入操作用户'){this.value='';}" />
								</li> 								
								<li>
									<input id="ip" name="ip" style="width:100px" type="text" class="shurukuangkais" value="请输入用户IP" onblur="if(this.value==''){this.value='请输入用户IP';}" onfocus="if(this.value=='请输入用户IP'){this.value='';}" />
								</li> 
<!-- 								<li>
									<input id="modelname" name="modelname" style="width:100px" type="text" class="shurukuangkais" value="请输入模块名称" onblur="if(this.value==''){this.value='请输入模块名称';}" onfocus="if(this.value=='请输入模块名称'){this.value='';}" />
								</li>  -->
							</ul>
						</div>
				</div>
				<div class="dashujtiaojianxuanxiangkuan_lie">
				          <div class="tiaojian_key">流水号：</div>
				          <div class="tiaojian_values">
				            <ul class="tiaojian_values_limian">
				              <li><input id="lshSelect" type="text" class="shurukuangkais" placeholder='请输入流水号'/></li>
				              <li><span class="buchongdbiaotdsw">号牌号码：</span>
				              <input id="hphmSelect" type="text" class="shurukuangkais" placeholder='请输入号牌号码'/></li>
				            </ul>
				          </div>
		        </div>
				<div class="chaxunchongzhianniu">
					<a href="javascript:queryDataGrid()" class="congzhim">查询</a>
				</div>
			</div>
		</div>
	</div>
<div data-options="region:'center',border:false" style="padding-left:10px;padding-right: 10px;">
	<div class="easyui-layout xinxichaxunkuangz2" data-options="fit:true,border:false">
		<div class="tupianqiehuantop" data-options="region:'north',border:false" style="height: 32px">
             	<span class="chaxunjieguosd">搜索结果</span>
    		</div>
    		<div data-options="region:'center',border:false">
    			<table id="TableData" data-options="fit:true,striped:true,fitColumns:true"></table>
    		</div>
	</div>
</div>
<script type="text/javascript">
//设置指定日期
Date.prototype.format = function(fmt){
	var o = {"M+": this.getMonth()+1,        //月份
	"d+": this.getDate(),                    //日
	"h+": this.getHours(),                   //小时
	"m+": this.getMinutes(),                 //分
	"s+": this.getSeconds(),                 //秒
	"q+": Math.floor((this.getMonth()+3)/3), //季度
	"S" : this.getMilliseconds()             //毫秒
	};
	if(/(y+)/.test(fmt))
	fmt=fmt.replace(RegExp.$1,(this.getFullYear()+"").substr(4 - RegExp.$1.length));
	for(var k in o)
		if(new RegExp("("+ k +")").test(fmt))
	fmt= fmt.replace(RegExp.$1, (RegExp.$1.length==1)?(o[k]):(("00"+ o[k]).substr((""+o[k]).length)));
	return fmt;
}
function formatDatebox(value) { 
    if (value == null || value == '') {  
        return '';  
    }  
    var dt;  
    if (value instanceof Date) {  
        dt = value;  
    } else {  
        dt = new Date(value);  
    }  
  
    return dt.format("yyyy-MM-dd hh:mm:ss"); //扩展的Date的format方法(上述插件实现)  
} 
//获取日期getData(0)今天,getData(7)七天前
function getDatex(day){
	var zdate=new Date();
	var sdate=zdate.getTime();
	var edate=new Date(sdate-(day*24*60*60*1000)).format("yyyy-MM-dd hh:mm:ss");
	return edate;
}
$(function(){
	$('#dateTimeStart').datebox().datebox('calendar').calendar({
		validator:function(firstDate){
		var d1 = new Date();
		return firstDate<=d1;
		}
	})
	$("#dateTimeStart").datebox({
		onSelect:
			function(firstDate){
				$('#dateTimeEnd').datebox().datebox('calendar').calendar({
					validator:function(date){
					var d1 = new Date(firstDate.getFullYear(), firstDate.getMonth(), firstDate.getDate());
					var d2 = new Date();
					return d1<=date && date<=d2;
					}
				
				})
			}
		 });
	//设置日期初始值
	$("#dateTimeStart").datetimebox("setValue",getDatex(3));
	$("#dateTimeEnd").datetimebox("setValue",getDatex(0)); 
});
	$(function(){
			initTable();
	});
	//数据表
	function initTable(){
		$("#TableData").datagrid({
			url:'${ctx}/sysuserlog/findSysuserlog.htm',
			idField:'logid',
			fitColumns:true,
			border:false,
			//singleSelect:true,
			pagination: true,
			pageSize: 10,                //每页记录数      
           	pageList: [5, 10, 15, 20, 30, 50], //分页记录数数组 
			columns:[[
				{field:'lsh',title:'流水号',width:'120',align:'center',split:true},
				{field:'hphmmc',title:'号牌号码',width:'90',align:'center',split:true},
			  	{field:'yhdh',title:'操作用户',width:'170',align:'center',split:true},
			  	{field:'ip',title:'操作者IP',width:'150',align:'center',split:true},
			  	{field:'modelname',title:'模块名称',width:'200',align:'center',split:true},
			  	{field:'methoddesc',title:'操作描述',width:'200',align:'center',split:true},
			  	{field:'optypemc',title:'操作类型',width:'100',align:'center',split:true},
			  	{field:'dateTime',title:'操作时间',width:'140',align:'center',split:true,formatter: formatDatebox},
			  	{field:'cz',title:'查看详情',width:'100',align:'center',split:true,fixed:true,formatter:function(value,row,index){
			  		if(row.detailisnot=="1"){
			  			return "<a class=\"chense\" href=\"javascript:checkInfo('"+row.logid+"')\" >查看</a>";
			  		}else{
			  			return "<a class=\"chense5\" href=\"###\" >无详情</a>";	
			  		}
			  	}}
			]]
		});
	}
	//查看详情
	function checkInfo(_logid){
			parent.addTab("日志详情","${ctx}/sysuserlog/findYxsqxzByxhFirstIn.htm?logid="+_logid);
		} 
	
	//根据界面中的样件，过滤查询用户列表
	function queryDataGrid(){
		var hphm = $("#hphmSelect").val();
		var reg = /[\u4e00-\u9fa5]/g;//筛选是否有中文
		_hphm = hphm.replace(reg, "").toUpperCase();
		var dateTimeStart = $("input[name='dateTimeStart']").val();
		var dateTimeEnd = $("input[name='dateTimeEnd']").val();
		var optype =$("input[name='optype']").val();
		var yhdh = $("#yhdh").val() == "请输入操作用户" ? "":$("#yhdh").val();
		var ip = $("#ip").val() == "请输入用户IP" ? "":$("#ip").val();
		//var modelname = $("#modelname").val() == "请输入模块名称" ? "":$("#modelname").val();
		$("#TableData").datagrid("load",{
			optype:optype,
			ip:ip,
			//modelname:modelname,
			yhdh:yhdh,
			dateTimeStart:dateTimeStart,
			dateTimeEnd:dateTimeEnd,
			lsh:$("#lshSelect").val(),
		    hphm:_hphm
		});
	}
	
	
	function isNull(str){
		//如果str为boolean类型，将不支持后面的replace方法。
		if(typeof (str) == "boolean"){
			return false;
		}
		return (null == str || typeof (str) == "undefined" || str == "undefined" || ( typeof (str) == "string" && str.replace(/(^\s*)|(\s*$)/g, "") == ""));
	 }
</script>
</body>
</html>